package cn.wolfcode.trip.base.domain;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Getter;
import lombok.Setter;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

@Setter
@Getter
@JsonIgnoreProperties("handler")
public class Comment extends BaseDomain {
    public static final Integer MODELSTATE_TRAVEL = 1;//游记类型
    public static final Integer MODELSTATE_STRATEGYDETAILS = 2;//攻略类型
    public static final Integer MODELSTATE_DAILY = 3;//日报类型
    public static final Integer MODELSTATE_STRATEGYCOMMENT = 4;//点评类型


    //评论人
    private User user;
    //评论内容
    private String content;
    //评论时间
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GM+8")
    private Date commentTime;
    //评论文章
    private Article article;
    //评论模块
    private Integer modelState;
    //子评论
    private List<Comment> subComments = new ArrayList<>();
    //父id
    private Long parentId;

    public String getModelStateString(){
        String temp = "游记";
        if (MODELSTATE_STRATEGYDETAILS.equals(modelState)){
            temp = "攻略";
        }else if (MODELSTATE_DAILY.equals(modelState)){
            temp = "日报";
        }else if (MODELSTATE_STRATEGYCOMMENT.equals(modelState)){
            temp = "点评";
        }
        return temp;
    }

}